/** 指令枚举 */
enum IBusinessName {
	SCREEN_SHOT = 'screenshot',
	SCREEN_SHARE = 'screenShare',
	SEND_LINK = 'sendLink',
	SEND_VIDEO_LINK = 'sendVideoLink',
	SEND_SCANNER_CODE = 'sendScannerCode',
	CANCEL_SCANNER_CODE = 'cancelScannerCode',
	REQUEST_GEO_LOCATION = 'requestGeoLocation',
	FACE_COMPARE = 'faceCompare',
	SNAP_SHOT = 'snapShot',
	RECORD_SCREEN = 'recordScreen',
	CARD_COMPARE = 'cardCompare',
	SCREEN_MARK = 'screenMark',
	GET_GEO_LOCATION = 'getGeoLocaltion',
	SEND_SIGN = 'sendSign',
	FILL_FORM = 'fillForm',
	SEND_PDF = 'sendPDF',
	REGIONAL_SCREEN_RECORDING = 'regionalScreenRecording',
	SEND_KNOWLEDGE_BASE = 'sendKnowledgeBase',
	CUSTOMER_VIEW_MARK = 'customerViewMark'
}

enum IBusinessStatus {
	IDLE = 'idle',
	START = 'start',
	IN_PROGRESS = 'in-progress',
	REJECTED = 'rejected',
	CANCEL = 'cancel',
	FAILED = 'failed',
	DONE = 'done'
}

export interface Ring {
	bizScenarioId: string;
	group: string;
	invitationId: string;
	room?: string;
	sessionId: string;
	url: string;
	userData: IUserData;
}

export interface UA {
	ua: string;
	browser: { name: string; version: string; major: string };
	cpu: object;
	device: { vendor: string; model: string; type: string };
	engine: { name: string; version: string };
	os: { name: string; version: string };
}

export interface AgentInfo {
	avatar?: string;
	clientId?: string;
	fullName?: string;
	id: number;
	org: string;
	role?: string;
}

export interface AgentStatus {
	checkIn: boolean;
	logged: boolean;
	otherWork: boolean;
	ready: boolean;
}

export interface CheckedGroup {
	id: number;
	name: string;
}

export interface LoginForm {
	userName: string;
	password: string;
	org: string;
}

export interface IClient {
	id: number | string;
	label: string;
	audioOnly: boolean;
	clientId: string;
	videoId: string;
	muteStatus: boolean;
	streamMode: IStreamMode;
	role: 'customer';
	isScreenSyncMode: boolean;
	userName: string;
}

export interface IMembers {
	id: number | string | undefined;
	label: string;
	audioOnly: boolean;
	clientId: string;
	videoId: string;
	muteStatus: boolean;
	streamMode: IStreamMode;
	role: string;
	isScreenSyncMode: boolean;
	userName: string;
	isRobot?: boolean;
}

export interface IMembersProps {
	id: string;
	clientId: string;
	username: string;
	userRole: string;
	label: 'customer' | 'agent' | null;
}

export interface IUser {
	id?: number | string;
	clientId?: string;
	gender?: string;
	org?: string;
	userName?: string;
	fullName?: string;
	isRobot?: boolean;
	level?: null | number;
	isDisabled?: string;
	role?: string;
}

export interface StreamAdd {
	type: string;
	data: StreamAddData;
}

export interface IStream {
	id: string | undefined;
	label: string;
	audioOnly: boolean;
	clientId: string;
	videoId: string;
	muteStatus: boolean;
	streamMode: 'audio' | 'video';
	role: 'customer' | 'agent';
	isScreenSyncMode: boolean;
	userName: string;
	isRobot: boolean;
	isAudioMute: boolean;
	isVideoMute: boolean;
	networkStatus: string;
}

export enum IStreamLabel {
	CUSTOMER = 'customer',
	AGENT = 'agent',
	SCREEN = 'screen',
	RECORD_SCREEN = 'recordScreen',
	RECORD_SCREEN_REGIONAL = 'recordScreen-Regional'
}

export interface StreamEnd {
	type: string;
	data: StreamEndData;
}

export interface StreamEndData {
	streamLabel: string;
	streamInfo: StreamAddData;
}

export interface ISessionMembers {
	id: string;
	role: string;
	status: string;
	type: string;
	user: {
		id: number;
		name: string;
		org: string;
		profile: {
			isRobot: boolean;
		};
	};
}

export interface ICustomerLeave {
	data: {
		id: string;
		reason: '';
	};
}

export interface ICustomerJoin {}

export interface IUserData {
	callMediaType: 'audio' | 'video' | 'im';
	businessflowId?: string;
	customerRole: string;
	formId: string;
	fullName?: string;
	gender?: string;
	homeAddress?: string;
	idCard?: string;
	isScreenSyncMode: boolean;
	name: string;
	phoneNumber: string;
	receiveMediaType: 'audio' | 'video' | 'im';
	microphoneStatus?: 'mute' | 'unmute';
	service: string | number;
	specifyAgent: null;
	ua: UA;
	userId: string | number;
	userName: string;
	inviteMediaType?: 'audio' | 'video' | 'im';
}

export interface ICallUserData {
	invitationId: string;
	bizScenarioId: string;
	group: string;
	room: string | undefined;
	sessionId: string;
	userData: IUserData;
	media: string;
}

export interface IAnswerMediaData {
	customerClientType: any;
	customerSendMessage: any[];
	// participantId: string;
	// publicationId: string;
	sessionData: {
		clientId: string;
		customerClientType: string;
		members: IJoinedMembers[];
		recordingId: string;
		refersh_ticket_time: number | null;
		roomId: string;
		roomToken: string;
		sessionId: string;
		ticket: string;
	};
}

export interface IJoinedMembers {
	clientInfo?: { type: string; version: string };
	id: string;
	role: 'customer' | 'agent';
	type?: string;
	status?: string;
	user: {
		customerLevel: number | null;
		id: number;
		name: string;
		org: string;
		profile: {
			fullName?: string;
			gender?: string;
			picture?: string;
			isRobot?: boolean;
		};
	};
}

export interface IRecordingPoint {
	recordingId: string;
	content: string;
	timePoint: number;
	userId: number;
	userName: string;
	userRole: string;
}

export interface IRecordingAlert {
	systemRecordingId: number | string;
	screenRecordingId: number | string;
	regionalScreenRecordingId: number | string;
}

export interface IStream {
	id: string | undefined;
	label: string;
	audioOnly: boolean;
	clientId: string;
	videoId: string;
	muteStatus: boolean;
	streamMode: 'audio' | 'video';
	role: string;
	isScreenSyncMode: boolean;
	userName: string;
}

export interface StreamAdd {
	type: string;
	data: StreamAddData;
}

export interface StreamAddData {
	audioOnly: boolean;
	id: string;
	videoId: string;
	streamLabel: string;
	isAudioMute: boolean;
	isVideoMute: boolean;
	userInfo: {
		clientId: string;
		customerRole: string;
		userName: string;
		role: 'customer' | 'agent';
		from?: any;
	};
}

export interface IAgentJoin {
	data: {
		id: string;
		role: string;
		user: {
			id: number;
			name: string;
			org: string;
			profile: {
				isRobot: boolean;
			};
		};
	};
}

export interface IRobotMembers {
	id: string;
	role: string;
	isRobot: boolean;
	userName: string;
}

export interface IAgentLeave {
	data: {
		id: string;
		reason: '';
	};
}

export interface ISystemRecordPoint {
	recordingId: string;
	content: string;
	timePoint: number;
	userId: number | string;
	userName: string;
	userRole: string;
}

export interface IAgentStatus {
	logged: boolean; //登入
	ready: boolean; //就绪
	otherWork: boolean; //小休
	checkIn: boolean; //签入
	isChief: boolean;
	afterWork: boolean;
}

export interface ICollectionVariable {
	id: string | number;
	key: string;
	desc: string;
	property: string;
	content: string;
	initMode?: string;
	scenId?: string;
	url?: string;
}

export interface IResponseVariable {
	userName: string;
	clientId: string;
	data: IVariableList[];
	userRole: string;
}

export interface ITestimonyBoardId {
	whiteboardId: string;
	clientId: string;
}

export interface IAcceptCallMode {
	callMediaType: IStreamMode;
	receiveMediaType: IStreamMode;
	microphoneStatus: IMicrophoneStatus;
}

export interface IStream {
	id: string | undefined;
	label: string;
	audioOnly: boolean;
	clientId: string;
	videoId: string;
	muteStatus: boolean;
	streamMode: 'audio' | 'video';
	role: 'customer' | 'agent';
	customerRole?: string;
	isScreenSyncMode: boolean;
	userName: string;
}

export type IPermissionName = 'geolocation' | 'notifications' | 'persistent-storage' | 'push' | 'screen-wake-lock' | 'xr-spatial-tracking' | 'camera' | 'microphone';

export type IStreamMode = 'audio' | 'video' | 'im';

export type IMicrophoneStatus = 'mute' | 'unmute';

export interface IAudioConstraints extends MediaTrackConstraints {
	source?: 'mic';
}
export interface IVideoConstraints extends MediaTrackConstraints {
	source?: 'camera';
	resolution?: { width: number; height: number };
}

export type ILayout = 'full' | 'left' | 'close' | 'right';

export type ICurrentTab = 'sessionService' | 'managementService' | 'agentManagement' | 'serviceRecord'; // 通话服务，服务记录， 管理后台， 在线坐席管理

export interface IPreferenceSettings {
	deviceConfigHidden?: boolean; // 是否隐藏设备设置(音视频设备+虚拟背景+水印)
	virtualBackgroundConfigHidden?: boolean; // 是否隐藏虚拟背景
	watermarkConfigHidden?: boolean;
	languageConfigHidden?: boolean;
	acceptCallConfigHidden?: boolean;
	floatAlertConfigHidden?: boolean;
	managementMenuHidden?: boolean;
	agentManagemenMenuHidden?: boolean;
	chatBoxHidden?: boolean;
	layoutConfigHidden?: boolean;
	bizPannelHidden?: boolean;
	qualityTestingResultHidden?: boolean; // 质检结果是否显示
	isImagePreviewHidden?: boolean;
	isCallProgressHidden?: boolean;
	userInfoHidden?: boolean;
	ignoreTools: number[];
	headerMenus: { label: string; i18nKey: string; key: string }[]; // 头部菜单
	isRecordHidden: boolean; // 控制显示双录按钮(坐席开启录制/停止录制)
	isNotifyCustomerMediaUpgrade?: boolean; // 是否通知访客媒体升级
	disableAudioAnswerToVideoCall?: boolean; // true: 视频进电显示语音和视频按钮，false:视频进电只显示视频按钮
	awsFileUrl?: string; // aws文件存储，配置文件预览url
}

export interface IDefaultMediaOptions {
	cameraStreamAudioConstraints: { deviceId: string | undefined; source: 'mic' };
	cameraStreamVideoConstraints: { deviceId: string | undefined; frameRate: number; resolution: { width: number; height: number }; source: 'camera' };
	cameraPublishOptions: {
		audio: { codec: { name: string } }[];
		video: { codec: { name: string }; maxBitrate: number }[];
	};
	screenStreamAudioConstraints: { source: 'camera' | 'screen-cast' | undefined };
	screenStreamVideoConstraints: { frameRate: number; resolution: { width: number; height: number }; source: 'camera' | 'screen-cast' | undefined };
	screenPublishOptions: {
		audio: { codec: { name: string }; maxBitrate: number }[];
		video: { codec: { name: string }; maxBitrate: number }[];
	};
}

export interface WhiteBoardInfo {
	hostName: string;
	whiteboardPath: string;
}

export interface IOtherWork {
	endSessionOtherWork: 'off' | 'on'; //
	timeoutOtherWork: 'off' | 'on';
	endSessionReason: string;
	timeoutReason: string;
}

export interface ILoginData {
	username: string;
	password: string;
	org: string;
}

export interface IPocSetting {
	autoAnswer: boolean;
	autoReady: boolean;
	autoCheckin: boolean;
}

export interface IAgentProps {
	customerLevel: null | number | string;
	id: number;
	isDisabled: 'N' | 'Y';
	isRobot: boolean;
	org: string;
	profile: { isRobot: boolean };
	role: 'agent' | 'customer';
	schedulingAttributes: any;
	userName: string;
	_id: number;
}

export interface User {
	customerLevel: null | number | string;
	id: number;
	isDisabled: 'N' | 'Y';
	isRobot: boolean;
	org: string;
	profile: { isRobot: boolean };
	role: 'agent' | 'customer';
	schedulingAttributes: any;
	userName: string;
	_id: number;
}

export interface Urls {
	amsurl: string;
	backendurl: string;
	domainType: 'private' | 'public';
	icbcAxaBackendUrl: string;
	rtmpServer: string;
	turnserverCredential: string;
	turnserverUrl: string;
	turnserverUsername: string;
}

export interface GroupList {
	businessFlowId: null | string | number;
	createdAt: Date;
	createdBy: number;
	customizedPolicy: any[];
	defaultPolicy: 'least-used' | 'idlest' | 'random' | 'round-robin' | 'last-used';
	formTemplates: null | any[];
	id: number;
	isChief: number;
	name: string;
	org: string;
	updatedAt: null | Date;
	updatedBy: null | number;
	workflowSteps: null | any[];
}

export interface LoginResponseProps {
	backendUrl?: string;
	groupsList?: IValidGroups[];
	rtmpServer?: string;
	token?: string;
	user?: IAgentProps;
	isInitPwd?: string;
	pwdUpdateDeadline?: string;
	isExpired?: boolean;
}

export interface IValidGroups {
	businessFlowId: null | string | number;
	createdAt: Date;
	createdBy: number;
	customizedPolicy: any[];
	defaultPolicy: 'least-used' | 'idlest' | 'random' | 'round-robin' | 'last-used';
	formTemplates: null | any[];
	id: number;
	isChief: number;
	name: string;
	org: string;
	updatedAt: null | Date;
	updatedBy: null | number;
	workflowSteps: null | any[];
}

export interface IChiefGroups {
	isTeamLeader: false;
	groupId: number | any;
}

export interface ITicketInfo {
	agentId: string;
	refersh_ticket_time: number;
	ticket: string;
	id?: string;
}

export interface INITParams extends IPreferenceSettings {}

export type IEvent = 'error' | 'success' | 'stream';

export interface ICallProgressGroups {
	groupName?: string;
	groupId?: number;
	waitingNum?: number;
}

//操作枚举
export enum IOperationName {
	INVITE = 'invite'
}

export enum IOperationType {
	ADD = 'add',
	REMOVE = 'remove'
}

export type NetworkStatus = 'connected' | 'reconnect_failed' | 'reconnecting' | 'offline' | 'online' | 'reconnect_failed' | 'ping-connected' | 'ping-timeout' | 'error' | '';

export interface IRemoteStatus {
	id: number | string;
	status: 'connected' | 'reconnect_failed' | 'reconnecting';
}
export interface AnswerProps {
	sessionData: SessionDataProps;
	publicationId: string;
	[propsName: string]: any;
}

export interface SessionDataProps {
	clientId: string;
	roomId: string;
	recordingId: string;
	members?: any[];
	[propsName: string]: any;
}

export interface IMediaDevices {
	audioConstraints: IAudioConstraints;
	videoConstraints: IVideoConstraints;
	publishOptions: any;
}

export enum ISessionEventKey {
	onStreamAdd = 'onStreamAdd',
	onStreamEnd = 'onStreamEnd',
	onCustomerQuitSession = 'onCustomerQuitSession',
	onCustomerJoinSession = 'onCustomerJoinSession',
	onAgentJoinSession = 'onAgentJoinSession',
	onAgentQuitSession = 'onAgentQuitSession',
	ccsError = 'ccsError',
	systemError = 'systemError'
}

export interface IBackgroundList {
	id: number;
	api: string;
	apiClear: string;
	url: string;
	abbreviatedUrl: string;
	fileName: string;
	blurRadius?: number;
	type: 'no' | 'normal' | 'fuzzy';
	isDefault: boolean;
}

export interface IWatermarkImageList {
	id: number;
	url: string;
	abbreviatedUrl: string;
	position: number;
	fileName: string;
	type: 'no' | 'normal' | 'fuzzy';
	isDefault: boolean;
}

export interface IVariableList {
	id: number;
	scenId?: number;
	roleId?: number | null;
	name?: string;
	roleName?: string;
	linkedKey: string;
	initMode: string;
	type: string;
	url: any | null;
	method: any | null;
	params: any | null;
	dataMasking: any | null;
	isDefault: boolean;
	value: any | null;
	isDisabled?: boolean;
}

export interface IRoleWithBusiness {
	id: number;
	name: string;
	scenId: number;
}

export type TIgnoreLinkedKey = 'customerId' | 'fullName' | 'idCardNo' | 'picture' | 'gender';

export interface IQualityTestingResult {
	id?: number | string;
	isPass?: boolean; //是否通过
	org: string;
	scenId: number | string;
	sessionId: string;
	name: string; //质检名称
	category: string; //质检分类。1, 2,3,4分别代表：人脸对比，活体检测，客户敏感词，坐席敏感词
	detectionValue?: any; //质检检测值
	thresholdValue?: any; //阈值
	badword: any; //违规词
	clientId: string; //被检测方clientId
	minusPoint?: number | string; //	扣分
	createdBy?: number | string;
	createdAt?: number | string;
	updatedBy?: any;
	updatedAt?: any;
	client: {
		//被检测方信息
		clientRole: string;
		userName: string;
		customerRole?: string;
	};
}

export interface IRenderedStream {
	clientId: string;
	stream: MediaProvider;
}

export interface GroupSkill {
	id: number;
	name: string;
}

export interface FileOptions {
	id: number;
	url: string;
	name: string;
	size: number;
	title: string;
}

export interface TTSTalk {
	id: number;
	org: string;
	scenId: number;
	title: string;
	content: string;
	createdBy: number;
	createdAt: string;
	updatedBy: number;
	updatedAt: string;
}

export interface BusinessFile {
	id: number;
	org: string;
	scenId: string | number;
	type: 'document' | 'video';
	title: string;
	content: string;
	createdBy: number;
	createdAt: string;
	fileSize: number;
	fileName: string;
}

// export interface IUpgradeData {
// 	type: string; // 'request-upgrade'|'accept-upgrade'|'reject-upgrade'|'cancel-upgrade'
// 	from: any;
// 	to: any;
// 	media: any; //
// }

export interface Scene {
	agentTtsOption: object | null;
	aiBizflow: number;
	createdAt: string;
	createdBy: number;
	drawTextOptions: DrawTextOption;
	humanBizflow: number;
	id: number;
	isHumanAsrOn: boolean;
	isRealTimeQualityOn: null | boolean;
	name: string;
	org: string;
	ringingDuration: number;
	schedPolicy: SchedPolicy;
	status: boolean;
	updatedAt: string;
	isSummaryOn: boolean;
}

interface DrawTextOption {
	agent: boolean;
	customer: boolean;
	recording: boolean;
}

interface SchedPolicy {
	defaultPolicy: string;
	customizedPolicy: string[];
}

export type Tentry = 'enrtyManagement' | 'invalidAccount' | 'otherPersonLogin';

export interface SessionClient {
	fromUser: {
		avatar: string | undefined;
		role: 'customer' | 'agent';
		customerRole: string;
		isRobot: boolean;
		name: string;
	};
	data: {
		label: string;
		clientId: string;
		role: 'customer' | 'agent';
		isRobotStream: boolean;
		status: 'idle' | 'permission' | 'publish' | 'published';
		businessType: 'notice_media_progress';
	};
}

export interface SelectAgentOptions {
	id: number;
	value: string;
	label: string;
	status: AgentServiceStatus;
	fullName: string;
}

export interface BizscenariosAgent {
	id: number;
	status: AgentServiceStatus;
	userName: string;
	fullName: string | undefined;
	isRobot: boolean;
}

export type AgentServiceStatus = 'offline' | 'notReady' | 'ready' | 'ringing' | 'serving' | 'afterWork' | 'otherWork';

export { IBusinessName, IBusinessStatus };
